package com.lz.mycompcalculator.guide;


import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;


public class OnboardingActivity extends AppCompatActivity {

    private ViewPager2 viewPager;
    private GuidePagerAdapter pagerAdapter;
    private Button startTraining;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        getSupportActionBar().hide();
        viewPager = findViewById(R.id.view_pager);
        pagerAdapter = new GuidePagerAdapter(this.getSupportFragmentManager());
        viewPager.setAdapter(pagerAdapter);
        startTraining = findViewById(R.id.Start_Training_id);

        startTraining.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this,activity)
            }
        });
    }

    private class GuidePagerAdapter extends FragmentStateAdapter {

        public GuidePagerAdapter(FragmentManager fragmentManager) {
            super(fragmentManager, getLifecycle());
        }

        @Override
        public Fragment createFragment(int position) {
            // 返回指定位置的页面片段
            switch (position) {
                case 0:
                    return new GuideFragment1();
                case 1:
                    return new GuideFragment2();
                case 2:
                    return new GuideFragment3();
                default:
                    return null;
            }
        }

        @Override
        public int getItemCount() {
            // 返回页面总数
            return 3;
        }
    }

    public static class GuideFragment1 extends Fragment {

        public GuideFragment1() {
            // Required empty public constructor
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            // Inflate the layout for this fragment
            View view = inflater.inflate(R.layout.activity_onboarding1, container, false);
            // 在这里可以对布局中的视图进行操作或设置监听器等
            return view;
        }
    }

    public static class GuideFragment2 extends Fragment {

        public GuideFragment2() {
            // Required empty public constructor
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            // Inflate the layout for this fragment
            View view = inflater.inflate(R.layout.activity_onboarding2, container, false);
            // 在这里可以对布局中的视图进行操作或设置监听器等
            return view;
        }
    }

    public static class GuideFragment3 extends Fragment {

        public GuideFragment3() {
            // Required empty public constructor
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            // Inflate the layout for this fragment
            View view = inflater.inflate(R.layout.activity_onboarding3, container, false);
            // 在这里可以对布局中的视图进行操作或设置监听器等
            return view;
        }
    }
}